package com.cjkj.applet.controller;

import com.cjkj.applet.service.EquipmentService;
import com.cjkj.common.core.constant.EquipmentConstants;
import com.cjkj.common.core.web.controller.BaseController;
import com.cjkj.common.core.web.domain.AjaxResult;
import com.cjkj.system.api.domain.request.EquipmentHistoryReq;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 设备数据
 */
@RestController
@RequestMapping("/equipment")
public class EquipmentController extends BaseController {

    @Resource
    private EquipmentService equipmentService;

    /**
     * 查询睡眠垫实时数据
     * @param visitNo 患者就诊号
     * @return
     */
    @GetMapping("/getMonitorPadRealTimeData")
    public AjaxResult getMonitorPadRealTimeData(@RequestParam("visitNo") Long visitNo){
        return AjaxResult.success(equipmentService.getMonitorPadRealTimeData(visitNo));
    }

    /**
     * 睡眠监测垫历史数据
     * @param req 患者就诊号
     * @return
     */
    @GetMapping("/getMonitorHistoryData")
    public AjaxResult getMonitorHistoryData(@Valid EquipmentHistoryReq req){
        req.setEquipmentType(EquipmentConstants.EQUIPMENT_TYPE_MONITOR_PAD_TYPE);
        return equipmentService.getMonitorHistoryData(req);
    }

    /**
     * 查询多参数监测仪实时数据
     * @param visitNo 患者就诊号
     * @return
     */
    @GetMapping("/getBraceletRealTimeData")
    public AjaxResult getBraceletRealTimeData(@RequestParam("visitNo") Long visitNo){
        return AjaxResult.success(equipmentService.getBraceletRealTimeData(visitNo));
    }

    /**
     * 查询多参数监测仪历史数据
     * @param req 患者就诊号
     * @return
     */
    @GetMapping("/getBraceletHistoryData")
    public AjaxResult getBraceletHistoryData(@Valid EquipmentHistoryReq req){
        req.setEquipmentType(EquipmentConstants.EQUIPMENT_TYPE_SMART_BRACELET_TYPE);
        return equipmentService.getBraceletHistoryData(req);
    }

    /**
     * 查询多参数监测仪电量数据
     * @return
     */
    @GetMapping("/getBraceletBatteryData")
    public AjaxResult getBraceletBatteryData(@RequestParam("equipmentNo") String equipmentNo){
        return AjaxResult.success(equipmentService.getBraceletBatteryData(equipmentNo));
    }

    /**
     * 查询心电血压监测仪实时数据
     * @param visitNo 患者就诊号
     * @return
     */
    @GetMapping("/getEBRealTimeData")
    public AjaxResult getEBRealTimeData(@RequestParam("visitNo") Long visitNo){
        return AjaxResult.success(equipmentService.getEBRealTimeData(visitNo));
    }

    /**
     * 查询多参数监测仪电量数据
     * @return
     */
    @GetMapping("/getTj03BatteryData")
    public AjaxResult getTj03BatteryData(@RequestParam("equipmentNo") String equipmentNo){
        return AjaxResult.success(equipmentService.getTj03BatteryData(equipmentNo));
    }

    /**
     * 查询心电血压监测仪历史数据
     * @param req 患者就诊号
     * @return
     */
    @GetMapping("/getEBHistoryData")
    public AjaxResult getEBHistoryData(@Valid EquipmentHistoryReq req){
        req.setEquipmentType(EquipmentConstants.EQUIPMENT_TYPE_EB_TYPE);
        return equipmentService.getEBHistoryData(req);
    }

    /**
     * 获取调试数据
     * @param equipmentNo 设备编号
     */
    @GetMapping("/getDebugData")
    public AjaxResult getDebugData(@RequestParam("equipmentNo") String equipmentNo){
        return AjaxResult.success(equipmentService.getDebugData(equipmentNo));
    }
}